<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<title>订单中心</title>
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/api.css"/>
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/order-new.css?v=8"/>
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/fakeLoader.css">
    <link rel="stylesheet" type="text/css" href="{php echo $this->cur_mobile_path}/css/goods-two.css?v=15"/>
    <script src="{php echo $this->cur_mobile_path}/script/jquery-1.8.3.min.js"></script>
    <script type="text/javascript" src="https://api.map.baidu.com/api?ak=5PESLgvMcSbSUbPjmDKgvGZ3&v=2.0&services=false"></script>
    <link rel="stylesheet" href="{php echo $this->cur_mobile_path}/mvalidate/validate.css" />
    <script type="text/javascript" src="{php echo $this->cur_mobile_path}/mvalidate/jquery-mvalidate.js" ></script>
    {php $style_list_base = $setting['style_list_base'];}
    <style>
        .button.button-fill {
            color: #fff;
            background: {$style_list_base};
            border: none;
            line-height: 50px;
        }

        .label-switch input[type=checkbox]:checked+.checkbox {
            background: {$style_list_base};
        }
    </style>
</head>
<body>
<div class="fakeloader"></div>
<div id="wrap">
    <header class="bar bar-nav">
        <a class="button button-link button-nav pull-left" href="javascript:void(0)" onclick="history.go(-1)">
            <span class="icon-left"></span>
        </a>
        <h1 class="title">
            {if $store['is_wxapp_check']==0}
            确认订单
            {else}
            您点的菜单
            {/if}
        </h1>
        <a class="button button-link button-nav pull-right" href="javascript:void(0)" onclick="location.reload();">
            刷新
        </a>
    </header>
    {if $flag==true}
    <div class="content">
        <div class="list-block">
            <ul class="full-width-form">
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">手机号码:</div>
                        <div class="item-input">
                            <input type="text" name="entry_mobile" id="entry_mobile"
                                   placeholder="请输入手机号码">
                        </div>
                    </div>
                </li>
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label"></div>
                        <div class="item-input">
                            <input type="button" onclick="getcheckcode(this);" class="button vcode" value="获取验证码" style="height: 30px"/>
                        </div>
                    </div>
                </li>
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">验证码:</div>
                        <div class="item-input">
                            <input type="text" name="entry_checkcode" id="entry_checkcode"
                                   placeholder="">
                        </div>
                    </div>
                </li>
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-input" style="padding-bottom: 10px;padding-top: 10px;">
                            <a href="#" class="button button-fill" id="btncheck"
                               style="line-height:40px;">
                                提交
                            </a>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <script type="text/javascript">
        var intervalId,buttonObj;
        //发送下一条短信需要间隔的秒数
        var seconds = 60;
        function getcheckcode(clickObj){
            var url = "{php echo $this->createMobileurl('GetCheckCode', array('from_user' => $from_user), true);}";
            var storeid = "{$storeid}";
            var mobile = $("#entry_mobile").val();
            var req = {
                mobile: mobile,
                storeid: storeid
            }

            if (!checkMobile(req.mobile)) {
                return false;
            }

            clickObj.setAttribute("disabled", "disabled");
            clickObj.value = "正在发送，请稍候...";

            $.ajax({
                url: url,
                type:"post",
                data:req,
                dataType:"JSON",
                success: function(data) {
                    if (data.status == 1) {
                        clickObj.value = '发送成功';
                        buttonObj = clickObj;
                        intervalId = setInterval("ticker()",1000);
                    } else {
                        clickObj.value = '发送失败';
                        buttonObj = clickObj;
                        intervalId = setInterval("ticker()",1000);
                        alert('调试:' + data.msg);
                        return false;
                    }
                },
                error: function(data){
                    alert('网络异常哦!');
                    return false;
                }
            });
        }

        function ticker(){
            seconds --;
            if(seconds > 55){
                //提示消息显示5秒钟
            }else if(seconds>0){
                buttonObj.value = seconds+"秒后可重新获取";
            }else{
                clearInterval(intervalId);
                buttonObj.removeAttribute("disabled");
                buttonObj.value = "获取验证码";
                seconds = 60;
                buttonObj = null;
            }
        }

        $("#btncheck").click(function () {
            postmain2();
        });

        function postmain2() {
            $("#btncheck").hide();
            if (true) {
                var url = "{php echo $this->createMobileUrl('validatecheckcode', array('from_user' => $from_user), true)}";

                var mobile = $("#entry_mobile").val();
                var checkcode = $("#entry_checkcode").val();
                if (mobile == "") {
                    $.mvalidateTip('请输入手机号码！');
                    return false;
                }
                if (checkcode == "") {
                    $.mvalidateTip('请输入验证码！');
                    return false;
                }

                $.ajax({
                    url: url, type: "post", dataType: "json", timeout: "10000",
                    data: {
                        "mobile": mobile,
                        "checkcode": checkcode
                    },
                    success: function (data) {
                        if (data.status == 1) {
                            window.location.reload();
                        } else {
                            alert(data.msg);
                        }
                        $("#btncheck").show();
                    },error: function () {
                        alert("网络不稳定，请重新尝试!");
                    }
                });
            } else {
                $("#btncheck").show();
            }
        }
    </script>
    {else}
    <div class="content">
        {if $mode == 2}
        <div class="list-block">
            <ul class="full-width-form">
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">
                            配送方式:
                        </div>
                        <div class="item-input">
                            {if $store['is_delivery_mode1'] == 1}
                            <label class="label-checkbox item-content" style="float: left;padding-left:0px;">
                                <input type="radio" name="delivery_mode" value="1" onclick="tototal();" checked>
                                <div class="item-media">
                                    <i class="icon icon-form-checkbox">
                                    </i>
                                    <span>&nbsp;送餐上门</span>
                                </div>
                            </label>
                            {/if}
                            {if $store['is_delivery_mode2'] == 1}
                            <label class="label-checkbox item-content" style="float: left;padding-left:0px;">
                                <input type="radio" name="delivery_mode" value="2" onclick="tototal();"{if
                                       $store['is_delivery_mode1'] == 0} checked{/if}>
                                <div class="item-media">
                                    <i class="icon icon-form-checkbox">
                                    </i>
                                    <span>&nbsp;到店自提</span>
                                </div>
                            </label>
                            {/if}
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        {/if}
        <div class="list-block address-editor">
            <!--<div class="address-editor-ribbon"></div>-->
            <ul class="full-width-form">
                {if $mode == 1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">桌台/包厢:</div>
                        <div class="item-input" style="padding-right:30px; line-height:21px;color:#f00;">{$table_title}{if
                            $append==1}(加单){/if}</div>
                    </div>
                </li>
                {/if}
                {if $mode == 4}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">桌台:</div>
                        <div class="item-input">
                            <select name="tables" id="tables">
                                {loop $tablelist $item}
                                <option value="{$item['id']}" >{$item['title']}</option>
                                {/loop}
                            </select>
                        </div>
                    </div>
                </li>
                {/if}
                {if $mode == 2}

                {if $store['is_dispatcharea'] == 1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">配送地点:</div>
                        <div class="item-input" >
                            <select name="dispatcharea" id="dispatcharea">
                                <option value="0">请选择所在区域</option>
                                {loop $dispatchareas $row}
                                <option value="{$row['title']}">{$row['title']}</option>
                                {/loop}
                            </select>
                        </div>
                    </div>
                </li>
                {/if}

                {if $store['delivery_within_days'] != 0 && $store['is_show_deliverytime']==1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label" id="meal_date_tip">配送日期:</div>
                        <div class="item-input">
                            <select name="meal_date" id="meal_date" onchange="changeMealDate(this)">
                                {$select_mealdate}
                            </select>
                        </div>
                    </div>
                </li>
                {else}
                <input type="hidden" id="meal_date" value="" name="meal_date">
                {/if}
                {if $store['is_show_deliverytime']==1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label" id="meal_time_tip">配送时间:</div>
                        <div class="item-input">
                            <select name="meal_time" id="meal_time">
                                {$select_mealtime}
                            </select>
                        </div>
                    </div>
                </li>
                {/if}
                {if $delivery_radius>0}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">配送范围:</div>
                        <div class="item-input">
                            {if $delivery_radius>0}{$delivery_radius}公里{/if}
                        </div>
                    </div>
                </li>
                {/if}
                {/if}
                <!--多收餐地址-->
                {if $mode != 1 && $mode != 4}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label" id="con_tip">
                            {if $mode == 2}
                            收餐地址:
                            {else}
                            联系方式:
                            {/if}
                        </div>
                        <div class="item-input input-address" style="padding-right:30px; line-height:21px" id="mapaddress" name="mapaddress">
                            {if empty($useraddress)}
                            <a href="{php echo $this->createMobileUrl('useraddress', array('storeid' => $storeid, 'mode' => $mode, 'op' => 'display'), true)}">{if $mode == 2}点击添加您的收餐地址{else}点击添加您的联系方式{/if}</a>
                            {else}
                            {if $mode == 2}
                            {if !empty($useraddress['address'])}
                            {$useraddress['address']} {$useraddress['doorplate']}
                            <br/>
                            {/if}
                            {/if}
                            {$useraddress['realname']} {$useraddress['mobile']}
                            {/if}
                        </div>
                        <div class="item-input" style="width: 8%;" onclick="javascript:window.location.href='{php echo $this->createMobileUrl('useraddress', array('storeid' => $storeid, 'mode' => $mode, 'op' => 'display'), true)}'">
                            <img src="{php echo $this->cur_mobile_path}/image/edit.png" width="20px"/>
                        </div>
                    </div>
                </li>
                {/if}
                {if $mode==2 && $store['is_floor_money'] == 1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">
                            {$store['floor_tip']}:
                        </div>
                        <div class="item-input">
                            <label class="label-checkbox item-content" style="float: left;width:22%;">
                                <input type="radio" name="floor_money" value="2" onclick="tototal();" checked>

                                <div class="item-media">
                                    <i class="icon icon-form-checkbox">
                                    </i>
                                    <span>&nbsp;不需要</span>
                                </div>
                            </label>
                            <label class="label-checkbox item-content" style="float: left;width:18%;">
                                <input type="radio" name="floor_money" value="1" onclick="tototal();">
                                <div class="item-media">
                                    <i class="icon icon-form-checkbox">
                                    </i>
                                    <span>&nbsp;需要</span>
                                </div>
                            </label>
                        </div>
                    </div>
                </li>
                {/if}
                {if $mode == 1}
                {if $table['is_seat'] == 1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">座位:</div>
                        <div class="item-input">
                            <select name="seat" id="seat">
                                {loop $seatlist $seatitem}
                                <option value="{$seatitem['id']}" >{$seatitem['title']}</option>
                                {/loop}
                            </select>
                        </div>
                    </div>
                </li>
                {/if}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">用餐人数:</div>
                        <div class="item-input">
                            <select name="counts" id="counts" onchange="select_count(this)">
                                {if $append != 0}
                                <option value="0">不增加人数</option>
                                {/if}
                                {php for($i = 1;$i<20;$i++){}
                                <option value="{$i}" {if $pnum==$i}selected{/if}>{$i}</option>
                                {php }}
                            </select>
                        </div>
                    </div>
                </li>
                {/if}
            </ul>
        </div>
        <!--<div class="list-block">-->
        <!--<ul>-->
        <!--<li id="delivery-time-picker" class="item-content item-link">-->
        <!--<div class="item-inner">-->
        <!--<div class="item-title">送达时间</div>-->
        <!--<div class="item-after delivery-time-label selecttime">请选择送达时间</div>-->
        <!--</div>-->
        <!--</li>-->
        <!--</ul>-->
        <!--</div>-->
        {if $store['is_wxapp_check']==0}
        <div class="list-block">
            <ul class="full-width-form">
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">优惠券</div>
                        <div class="item-input">
                            <select name="coupon" id="coupon" onchange="select_coupon(this.value)">
                                {if empty($couponlist)}
                                <option value="0">无可用优惠券</option>
                                {else}
                                {loop $couponlist $item}
                                <option value="{$item['couponid']}">{$item['title']}</option>
                                {/loop}
                                {/if}
                            </select>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        {/if}
        <!--<div class="list-block">-->
        <!--<ul>-->
        <!--<li class="item-content item-link item-yh">-->
        <!--<div class="item-inner">-->
        <!--<div class="item-title">优惠券</div>-->
        <!--<div class="item-after delivery-time-label yhprice">无可用优惠券</div>-->
        <!--</div>-->
        <!--</li>-->
        <!--</ul>-->
        <!--</div>-->
        {if $store['is_wxapp_check']==0}
        <div class="list-block">
            <ul class="full-width-form">
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">备注:</div>
                        <div class="item-input">
                            <input maxlength="100" type="text" name="remark" id="remark" placeholder="{$store['remarkinfo']}">
                        </div>
                    </div>
                </li>
                <!--<li class="item-content">-->
                <!--<div class="item-inner">-->
                <!--<div class="item-title label">需要发票</div>-->
                <!--<div class="item-after">-->
                <!--<label class="label-switch">-->
                <!--<input type="checkbox">-->
                <!--<div class="checkbox"></div>-->
                <!--</label>-->
                <!--</div>-->
                <!--</div>-->
                <!--</li>-->
                <!--<li class="item-content item-zp" style="display: none;">-->
                <!--<div class="item-inner">-->
                <!--<div class="item-input">-->
                <!--<input maxlength="20" type="text" placeholder="输入公司或个人抬头">-->
                <!--</div>-->
                <!--</div>-->
                <!--</li>-->
            </ul>
        </div>
        {/if}
        <input type="hidden" id="paymode" value="{if $store['is_more_meal'] == 1}1{else}2{/if}">
        <input type="hidden" id="isfloor" value="2">
        <div class="list-block">
            <ul class="full-width-form">
                {if $mode <> 1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label" style="width:100%;">商品清单

                            {if $store['freeprice']!=0.00}(<font color="#f00">满{$store['freeprice']}免配送费</font>){/if}

                        </div>
                    </div>
                </li>
                <li class="item-content delivery-settlement-content">
                    <div class="item-inner delivery-item-list">
                        <div class="delivery-item">
                            {loop $cart $item}
                            {if $item['total']>0}
                            <div>
                                <div class="delivery-item-name">
                                    {$item['title']}
                                    {if !empty($item['optionname'])}
                                    [{$item['optionname']}]
                                    {/if}
                                </div>
                                <span class="delivery-item-count" style="color:#d0d0d0;">×{$item['total']}</span>
                                    <span class="delivery-item-price">
                                        {if $iscard==1 && !empty($item['memberprice'])}
                                        (会员)
                                        {/if}
                                        {$item['price']}
                                    </span>
                            </div>
                            {/if}
                            {/loop}
                        </div>
                    </div>
                </li>
                {else}

                {if $store['is_more_meal'] == 1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">
                            支付模式:
                        </div>
                        <div class="item-input">
                            <label class="label-checkbox item-content" style="float: left;width: 40%;">
                                <input type="radio" name="paymode" value="1" onclick="settype('1');" checked>
                                <div class="item-media">
                                    <i class="icon icon-form-checkbox">
                                    </i>
                                    <span>&nbsp;我来买单</span>
                                </div>
                            </label>
                            <label class="label-checkbox item-content" style="float: left;width: 45%;">
                                <input type="radio" name="paymode" value="2" onclick="settype('2');">

                                <div class="item-media">
                                    <i class="icon icon-form-checkbox">
                                    </i>
                                    <span>&nbsp;各付各的</span>
                                </div>
                            </label>
                        </div>
                    </div>
                </li>
                {/if}
                {loop $userlist $useritem}
                <li class="item-content">
                    <div class="item-inner" style="display: table;padding-top: 12px;">
                        <img src="{php echo tomedia($useritem['fans']['headimgurl']);}" style="width:20px;float:left;">
                             <span style="padding-left: 5px;">{$useritem['fans']['nickname']}
                             {if $useritem['from_user'] == $from_user}
                             (我)
                             {/if}
                             </span>
                    </div>
                </li>
                <li class="item-content delivery-settlement-content">
                    <div class="item-inner delivery-item-list">
                        <div class="delivery-item">
                            {loop $useritem['cart'] $item}
                            {if $item['total']>0}
                            <div>
                                <div class="delivery-item-name">
                                    {$item['title']}
                                    {if !empty($item['optionname'])}
                                    [{$item['optionname']}]
                                    {/if}
                                </div>
                                <span class="delivery-item-count" style="color:#d0d0d0;">×{$item['total']}</span>
                                    <span class="delivery-item-price">
                                        {if $iscard==1 && !empty($item['memberprice'])}
                                        (会员)
                                        {/if}
                                        {$item['price']}
                                    </span>
                            </div>
                            {/if}
                            {/loop}
                        </div>
                    </div>
                </li>
                {/loop}
                {/if}
                <li class="item-content delivery-settlement-content">
                    <div class="item-inner delivery-settlement">
                        <div>
                            商品总额<em id="show_goodsprice">{$setting['currency']} {$goodsprice}</em>
                        </div>

                        {if $mode==1 && $is_tea_money == 1}
                        <div>
                            {$teatip}<em id="show_tea">{$setting['currency']} {$totalteavalue}</em>
                        </div>
                        {/if}
                        {if $mode==2 && $store['is_floor_money'] == 1}
                        <div id="show_floor" style="display: none;">
                            {$store['floor_tip']}费<em>{$setting['currency']} {$store['floor_money']}</em>
                        </div>
                        {/if}
                        {if $mode==2 && $packvalue>0}
                        <div>
                            打包费<em>{$setting['currency']} {$packvalue}</em>
                        </div>
                        {/if}
                        {if $dispatchprice>0 && $mode==2}
                        {if $store['freeprice']>0}
                        {if $totalprice<=$store['freeprice']}
                        <div id="div_dispatchprice">
                            配送费
                            <em>{$setting['currency']} {$dispatchprice}</em>
                        </div>
                        {/if}
                        {else}
                        <div id="div_dispatchprice">
                            配送费<em>{$setting['currency']} {$dispatchprice}</em>
                        </div>
                        {/if}
                        {/if}
                        {if $mode==2}
                        {if $distance}
                        <div>
                            商家距离<em>{$distance}km</em>
                        </div>
                        {/if}
                        {/if}

                        {if $mode==1 && $service_rate>0}
                        <div id="show_service">
                            %{$service_rate}服务费<em>{$setting['currency']} 0</em>
                        </div>
                        {/if}
                        <div id="youhui">
                            已优惠<em>{$setting['currency']} 0</em>
                        </div>
                        <div class="curt" style="display:none">
                            优惠价<em>{$setting['currency']} 0.00</em>
                        </div>
                    </div>
                </li>
                {if $iscardsetting == 1}
                <li class="item-content">
                    <div class="item-inner">
                        <div class="item-title label">消费积分抵扣
                            (<font color="#f00">剩余:{$card['balance_score']}</font>)
                        </div>
                        <div class="item-after">
                            <label class="label-switch">
                                <input type="checkbox">
                                <div class="checkbox"></div>
                            </label>
                        </div>
                    </div>
                </li>
                <li class="item-content item-zp" style="display: none;">
                    <div class="item-inner delivery-settlement">
                        <div>
                            抵扣金额<em>{$setting['currency']} -{$balance_score}</em>
                        </div>
                    </div>
                </li>
                {/if}
                {if ($isnewuser == 1 && $coupon_obj1) || ($isnewuser == 0 && $coupon_obj2)}
                <style>
                    i {
                        width: 16px;
                        height: 15px;
                        display: inline-block;
                        line-height: 15px;
                        font-size: 10px;
                        margin-right: 5px;
                        text-align: center;
                        color: #fff;
                    }
                    .icon-bg1{ background:#70bc46;}
                    .icon-bg2{ background:#f07373;}
                    .icon-bg3{ background:#f1884f;}
                    .icon-bg4{ background:#f5a317;}
                </style>

                <li class="item-content delivery-settlement-content" id="show_coupon1" style="display: none;">
                    <div class="item-inner delivery-settlement">
                        {if $isnewuser == 1 && $coupon_obj1}
                        <div>
                            <i class="icon-bg1">新</i><span>{$coupon_obj1['title']}</span>
                            <em>{$setting['currency']} -{$coupon_obj1['dmoney']}</em>
                        </div>
                        {/if}
                        {if $isnewuser == 0 && $coupon_obj2}
                        <div>
                            <i class="icon-bg3">满</i><span>{$coupon_obj2['title']}</span>
                            <em>{$setting['currency']} -{$coupon_obj2['dmoney']}</em>
                        </div>
                        {/if}
                    </div>
                </li>
                {/if}
                <li class="item-content total">
                    <div class="item-inner delivery-settlement">
                        <div class="compute-total">
                            <!--<span><em>原价:</em>{$setting['currency']}309.00</span>  -->
                            <em><span style="color: #9d9d9d; font-size: 12px;">总计:</span><span class="totalprice_show" style="color:#f03737;">
                                    {$setting['currency']} {$totalprice}</span></em>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <input type="hidden" id="iscredit" name="iscredit" value="0">
        <input type="hidden" id="balance_score" name="balance_score" value="{$balance_score}">
        <input type="hidden" id="mode" value="{$mode}" name="mode">
        {if $mode!=4}
        <input type="hidden" id="tables" value="{$tablesid}" name="tables">
        {/if}
        <input type="hidden" id="service_rate" value="{$service_rate}" name="service_rate">
        <input type="hidden" id="servicevalue" value="0" name="servicevalue">
        <input type="hidden" id="teavalue" value="{$teavaule}" name="teavalue">
        <input type="hidden" id="totalteavalue" value="{$totalteavalue}" name="totalteavalue">
        <input type="hidden" id="totalfloorvalue" value="{$totalfloorvalue}" name="totalfloorvalue">
        <input type="hidden" id="packvalue" value="{$packvalue}" name="packvalue">
        <input type="hidden" id="totalprice" value="{$totalprice}" name="totalprice">
        <input type="hidden" id="goodsprice" value="{$goodsprice}" name="goodsprice">
        <input type="hidden" id="goodsprices" value="{$goodsprices}" name="goodsprices">
        <input type="hidden" id="totalcount" value="{$totalcount}" name="totalcount">
        <input type="hidden" id="limitprice" value="{$limitprice}" name="limitprice">
        <input type="hidden" id="dprice" value="" name="dprice">
        <input type="hidden" id="dlimitprice" value="{$dlimitprice}" name="dlimitprice">
        <input type="hidden" id="dlimitprices" value="{$dlimitprices}" name="dlimitprices">
        <input type="hidden" id="dispatchprice" value="{$dispatchprice}" name="dispatchprice">
        <input type="hidden" id="limitdispatchprice" value="{$store['freeprice']}" name="limitdispatchprice">
        <input type="hidden" id="over_radius" value="{$over_radius}" name="over_radius">
        <input type="hidden" id="btnstatus" value="0" name="btnstatus">
        <input type="hidden" name="lat" id="lat" value="{$fans['lat']}">
        <input type="hidden" name="lng" id="lng" value="{$fans['lng']}">
    </div>
</div>
<div class="popup" style="display: none;">
    <header class="bar bar-nav">
        <a class="button button-link button-nav pull-right close" href="#" style=" background:none; color:#ffe100">取消</a>
        <h1 class="title">选择优惠券</h1>
    </header>
    <div class="content native-scroll" style="bottom:0;">
        <div class="mint-hb">
            <div class="hb-con">
                <div class="left">
                    {$setting['currency']} <strong>15</strong><small>.0</small>
                </div>
                <div class="right">
                    <h4>新用户首单红包</h4>
                    <ul>
                        <li>·满15元可用</li>
                        <li>·限尾号9050手机可用</li>
                        <li>·2017-01-11到期</li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="mint-hb">
            <div class="hb-con">
                <div class="left">
                    {$setting['currency']} <strong>25</strong><small>.0</small>
                </div>
                <div class="right">
                    <h4>新用户注册红包</h4>
                    <ul>
                        <li>·满15元可用</li>
                        <li>·限尾号9050手机可用</li>
                        <li>·2017-01-11到期</li>
                    </ul>
                </div>
            </div>
        </div>
        <!--没有优惠券-->
        <div class="empty-list" style="display:none">
            <div class="empty-list-icon empty-list-icon-coupon"></div>
            <p class="empty-list-tip">无可用优惠券</p>
        </div>
    </div>
</div>
{if $store['is_wxapp_check']==0}
<nav class="bar bar-tab">
        <span class="delivery-pay-total">
        	还需支付 <strong>{$setting['currency']} {$totalprice}</strong>
        </span>
    <a href="#" class="button button-fill delivery-button-submit" id="btnselect">
        {if $append ==2}
        确认加菜
        {else}
        确认下单
        {/if}
    </a>
</nav>
{/if}
<div class="picker-modal picker-columns  remove-on-close">
    <header class="bar bar-nav">
        <button class="button button-link pull-left close-picker"  id="delivery-time-close">取消</button>
        <button class="button button-link pull-right close-picker" id="delivery-time-picker-ok">确定</button>
        <h1 class="title">选择送达时间</h1>
    </header>
    <div class="picker-modal-inner picker-items">
        <div class="picker-items-col picker-items-col-center mday">
            <div class="picker-items-col-wrapper" style="transform: translate3d(0px, 90px, 0px);">
                <div class="picker-item picker-selected">今天</div>
                <div class="picker-item">1月14日</div>
                <div class="picker-item">1月15日</div>
                <div class="picker-item">1月16日</div>
                <div class="picker-item">1月17日</div>
                <div class="picker-item">1月18日</div>
                <div class="picker-item">1月19日</div>
                <div class="picker-item">1月20日</div>
            </div>
        </div>
        <div class="picker-items-col picker-items-col-center mtime">
            <div class="picker-items-col-wrapper" style="transform: translate3d(0px, 90px, 0px);">
                <div class="picker-item picker-selected">立即配送（11:30）</div>
                <div class="picker-item">11:45</div>
                <div class="picker-item">12:00</div>
                <div class="picker-item">12:15</div>
                <div class="picker-item">12:30</div>
                <div class="picker-item">12:45</div>
                <div class="picker-item">13:00</div>
                <div class="picker-item">13:15</div>
                <div class="picker-item">13:30</div>
                <div class="picker-item">13:45</div>
                <div class="picker-item">14:00</div>
                <div class="picker-item">14:15</div>
                <div class="picker-item">14:30</div>
                <div class="picker-item">14:45</div>
                <div class="picker-item">15:00</div>
                <div class="picker-item">15:15</div>
                <div class="picker-item">15:30</div>
                <div class="picker-item">15:45</div>
                <div class="picker-item">16:00</div>
                <div class="picker-item">16:15</div>
                <div class="picker-item">16:30</div>
                <div class="picker-item">16:45</div>
                <div class="picker-item">17:00</div>
                <div class="picker-item">17:15</div>
                <div class="picker-item">17:30</div>
                <div class="picker-item">17:45</div>
                <div class="picker-item">18:00</div>
                <div class="picker-item">18:15</div>
                <div class="picker-item">18:30</div>
                <div class="picker-item">18:45</div>
                <div class="picker-item">19:00</div>
                <div class="picker-item">19:15</div>
                <div class="picker-item">19:30</div>
                <div class="picker-item">19:45</div>
                <div class="picker-item">20:00</div>
                <div class="picker-item">20:15</div>
                <div class="picker-item">20:30</div>
                <div class="picker-item">20:45</div>
                <div class="picker-item">21:00</div>
                <div class="picker-item">21:15</div>
                <div class="picker-item">21:30</div>
                <div class="picker-item">21:45</div>
                <div class="picker-item">22:00</div>
            </div>
        </div>
        <div class="picker-center-highlight">
        </div>
    </div>
</div>
    {/if}
</div>
<script>
    function settype(type) {
        $("#paymode").val(type);
        tototal();
    }
$(document).ready(function(e) {
	$('.selecttime').click(function(e) {
		$('.popup-overlay').addClass('modal-overlay-visible')
		$('.picker-modal').css({"display":"block"},400)
		$('.picker-modal').animate({"bottom":"260px"},400)		
	})	
	$('#delivery-time-picker-ok').click(function(e) {
		var mday=$('.mday .picker-selected').text()
		var mtime=$('.mtime .picker-selected').text()
		$('.selecttime').text(mday+mtime)
		$('.popup-overlay').removeClass('modal-overlay-visible')
		$('.picker-modal').animate({"bottom":"0"},400)		
	})
	$('#delivery-time-close').click(function(e) {
		$('.popup-overlay').removeClass('modal-overlay-visible')
		$('.picker-modal').animate({"bottom":"0"},400)		
	})
	//配送时间选择
	$('.mday .picker-item').click(function(e) {	
		$('.mday .picker-item').removeClass('picker-selected')
		$(this).addClass('picker-selected')	
		var index=$(this).index()
		var yheight=parseInt(36)*parseInt(index);
		yheight=(90-yheight)+'px';
		$(this).parent().css({"transform":"translate3d(0px,"+ yheight +", 0px)"})	
    });	
	$('.mtime .picker-item').click(function(e) {	
		$('.mtime .picker-item').removeClass('picker-selected')
		$(this).addClass('picker-selected')	
		var index=$(this).index()
		var yheight=parseInt(36)*parseInt(index);
		yheight=(90-yheight)+'px';
		$(this).parent().css({"transform":"translate3d(0px,"+ yheight +", 0px)"})	
    });	

//是否需要发票	
    $('.item-after .label-switch').click(function(e) {
		var bool=$(this).find('input').is(':checked')
		if(bool){
            $("#iscredit").val(1)
			$('.item-zp').css({"display":"block"})
		}else{
            $("#iscredit").val(0)
			$('.item-zp').css({"display":"none"})
		}
        tototal();
    });

//优惠券	
	$('.item-yh').click(function(e) {	
		$('.popup').css({"display":"block"})
		$('.popup').animate({"top":"0"},400)
		$('.popup-overlay').addClass('modal-overlay-visible')			
    });	
	$('.popup .close').click(function(e) {
		$('.popup').animate({"top":"100%"},400)	
		$('.popup-overlay').removeClass('modal-overlay-visible')
		var timer = setTimeout("close()",450)	
    });
	
	$('.popup .mint-hb').click(function(e) {
		var yhprice=$(this).children().find('.left strong').text()
		$('.item-inner .yhprice').text('{$setting['currency']} '+yhprice+'.00')//替换优惠内容
		$('.delivery-settlement .curt').css({"display":"block"})
		$('.delivery-settlement .curt em').text('{$setting['currency']} '+yhprice+'.00')
			
		$('.popup').animate({"top":"100%"},400)	
		$('.popup-overlay').removeClass('modal-overlay-visible')
		var timer = setTimeout("close()",450)	
    });
	

 });
 function close(){
	$('.popup').css({"display":"none"})	
	}	
</script>	
<div class="popup-overlay"></div>
<div class="modal" style=" margin-top: -100px;">
    <div class="modal-inner">
    	<div class="modal-title">请注意</div>
        <div class="modal-text">
        修改收餐地址需要<br>重新返回首页喔
        </div>
    </div>
    <div class="modal-buttons ">
        <span class="modal-button">修改地址</span>
        <span class="modal-button m-close">我再看看</span>
    </div>
</div>
<script>
$(document).ready(function(e) {
	$('.modal .m-close').click(function(e) {
		$('.modal').addClass('modal-out')
		var clos = setTimeout("clos()",400)
		$('.popup-overlay').removeClass('modal-overlay-visible')
    });
 });
 function setdefaultaddress(addr, username, tel, lat, lng)
 {
     var address = addr.split(' ');
     $("#mapaddress").val(address[0]);
     $("#address").val(address[1]);
     $("#username").val(username);
     $("#tel").val(tel);
     $("#lat").val(lat);
     $("#lng").val(lng);
     creatmap();
 }

 function inter(){
	$('.modal').addClass('modal-in')
 }
 function clos(){
	$('.modal').css({"display":"none"})
	$('.modal').removeClass('modal-in')
	$('.modal').removeClass('modal-out')
	}	
</script>	

<script src="{php echo $this->cur_mobile_path}/script/fakeLoader.min.js"></script>
<script type="text/javascript">
    function postmain() {
        var status = $("#btnstatus").val();
        var ordertype = $("#mode").val();
        var mealtime = $("#meal_date").val() + ' ' + $("#meal_time").val();
        if ($("#meal_date").val() == undefined) {
            if ($("#meal_time").val() == undefined) {
                mealtime = '';
            } else {
                mealtime = $("#meal_time").val();
            }
        }
        var dispatcharea = $("#dispatcharea").val();
        if (dispatcharea == undefined) {
            dispatcharea = '';
        } else if(dispatcharea == 0){
            $.mvalidateTip('请选择配送地点！');
            return false;
        }

        if (status == 0) {
//            return false;
        }

        var delivery_mode = $("input:radio[name='delivery_mode']:checked").val();

        $("#btnselect").hide();
        if (true) {
            var url = "{php echo $this->createMobileUrl('addtoorder', array('storeid' => $storeid, 'from_user' => $from_user), true)}";
            "{if $is_auto_address==1}"
            var address = $('#mapaddress').val() + ' ' + $("#address").val();
            "{else}"
            var address = '';
            "{/if}"

            var totalprice = parseFloat($("#totalprice").val());
            var couponid = $("#coupon").val();
            var append = "{$append}";
            var lat = $("#lat").val();
            var lng = $("#lng").val();
            var paymode = $("#paymode").val();
            var isfloor = $("#isfloor").val();
            var iscredit = $("#iscredit").val();

            $.ajax({
                url: url, type: "post", dataType: "json", timeout: "10000",
                data: {
                    "type": "add",
                    "lat":lat,
                    "iscredit":iscredit,
                    "delivery_mode":delivery_mode,
                    "lng":lng,
                    "total": totalprice,
                    "ordertype":ordertype,
                    "append":append,
                    "tables": $("#tables").val(),
                    "address":address,
                    "username": $("#username").val(),
                    "tel": $("#tel").val(), "sex": 1,
                    "order_id" :{$orderid},
                    "couponid" : couponid,
                    "meal_time": mealtime,
                    "paymode": paymode,
                    "dispatcharea":dispatcharea,
                    "counts": $("#counts").val(),
                    "servicevalue": $("#servicevalue").val(),
                    "seat_type": $("input:radio[name='seat_type']:checked").val(),
                    "seat": $("#seat").val(),
                    "isfloor": isfloor,
                    "remark": $("#remark").val(),
                    "carports": $("#carports").val()
                },
                success: function (data) {
                    if (data.message['code'] != 0) {
                        if (data.message['code'] == 2){
                            $.mvalidateTip("加菜成功");
                            var url = "{php echo $this->createMobileUrl('orderdetail', array(), true)}" + "&orderid=" + data.message['orderid'];
                        } else{
                            "{if $store['is_order_tip'] == 1}"
                            var url = "{php echo $this->createMobileUrl('paytip', array('sid' => $sid), true)}" + "&orderid=" + data.message['orderid'];
                            "{else}"
                            var url = "{php echo $this->createMobileUrl('pay', array('sid' => $sid), true)}" + "&orderid=" + data.message['orderid'];
                            "{/if}"
                        }
                        location.href = url;
                    } else {
                        $.mvalidateTip(data.message['msg']);
                    }
                    $("#btnselect").show();
                },error: function () {
                    $.mvalidateTip("订单提交失败！");
                }
            });
        } else {
            $("#btnselect").show();
        }
    }

    function tototal(){
        var goodstotal = parseFloat($("#goodsprice").val());
        var currency = "{$setting['currency']} ";

        "{if $store['is_more_meal'] == 1}"
        var paymode = $("input:radio[name='paymode']:checked").val();
        if (paymode == 2) { //各付各的
            var goodstotal = parseFloat($("#goodsprices").val());
            $("#show_goodsprice").html(currency + $("#goodsprices").val());
        } else {
            $("#show_goodsprice").html(currency + $("#goodsprice").val());
        }
        "{/if}"
        var iscredit = $("#iscredit").val();
        var balance_score = $("#balance_score").val();

        var limitdispatchprice = parseFloat($("#limitdispatchprice").val());//满多少免配送费
        var dispatchprice = parseFloat($("#dispatchprice").val());//配送费
        var packvalue = parseFloat($("#packvalue").val());//打包费
        var dprice = $("#dprice").val();//优惠抵扣
        var dlimitprice = $("#dlimitprice").val();
        var dlimitprices = $("#dlimitprices").val();

        var service_rate = parseFloat($("#service_rate").val());//服务费
        var servicevalue = 0;//服务费

        "{if $is_tea_money==1}"
        var totalteavalue = parseFloat($("#totalteavalue").val());//茶位费
        "{else}"
        totalteavalue = 0;
        "{/if}"

        "{if $is_floor_money==1}"
        var totalfloorvalue = parseFloat($("#totalfloorvalue").val());//送货上楼费
        "{else}"
        totalfloorvalue = 0;
        "{/if}"

        var isfloor = $("input:radio[name='floor_money']:checked").val();
        var delivery_mode = $("input:radio[name='delivery_mode']:checked").val();

        var teavalue = parseFloat($("#teavalue").val());//茶位费

        mode = $("#mode").val();
        var pricedetail = '';
        if (mode == 2) { // 外卖
            if (delivery_mode == 1) {
                endTotal = goodstotal + dispatchprice;//商品 + 配送费
                if (limitdispatchprice > 0) { //满多少免配送费
                    if (goodstotal >= limitdispatchprice) { //免配送费
                        endTotal = goodstotal;
                    }
                }

                $('#div_dispatchprice').css({"display":"block"},400)
                $("#meal_date_tip").html('配送日期：');
                $("#meal_time_tip").html('配送时间：');
                $("#con_tip").html('收餐地址：');

            } else { //自提
//                meal_date_tip
                $("#con_tip").html('联系方式：');
                $("#meal_date_tip").html('自提日期：');
                $("#meal_time_tip").html('自提时间：');
                endTotal = goodstotal;
                $('#div_dispatchprice').css({"display":"none"},400)
            }
            endTotal = endTotal + packvalue;
            if (isfloor == 1) {
                $('#show_floor').css({"display":"block"},400)
                $("#isfloor").val(1)
                endTotal = endTotal + totalfloorvalue;
            } else {
                $("#isfloor").val(2)
                $('#show_floor').css({"display":"none"},400)
            }
        } else if (mode == 1) { // 店内
            endTotal = (goodstotal + totalteavalue);//商品 + 茶位费
        } else {
            endTotal = goodstotal;
        }

        //优惠抵扣
        if (dprice != '') {
            dprice = parseFloat(dprice);
            pricedetail = pricedetail + '-' + dprice;
            endTotal = endTotal - dprice;

        }
        $("#show_coupon1").hide();
        "{if $store['is_more_meal'] == 1}"
            if (paymode == 2) { //各付各的
                if (dlimitprices > 0) {
                    dlimitprice = parseFloat(dlimitprices);
                    $("#show_coupon1").show();
                    endTotal = endTotal - dlimitprice;
                }
            } else {
                if (dlimitprice > 0) {
                    dlimitprice = parseFloat(dlimitprice);
                    $("#show_coupon1").show();
                    endTotal = endTotal - dlimitprice;
                }
            }

        "{else}"

        if (dlimitprice > 0) {
            $("#show_coupon1").show();
            dlimitprice = parseFloat(dlimitprice);
            endTotal = endTotal - dlimitprice;
        }
        "{/if}"
        $('#totalprice').val(endTotal);
        if (mode == 1) { // 店内
            if (service_rate > 0) {
                //服务费
                servicevalue = endTotal * service_rate / 100;
                $("#servicevalue").val(servicevalue) ;
                endTotal = endTotal + servicevalue;
                $("#show_service").html(service_rate +'%服务费:<em>{$setting['currency']} ' + servicevalue + '</em>');
            }
        }

        endTotal = parseFloat(endTotal).toFixed(2) * 100/100;
        if (endTotal > 0) {
            $("#btnstatus").val('1');
        }
        if (iscredit == 1) {
            endTotal = endTotal - balance_score;
        }

        $(".totalprice_show").text(endTotal);
        $(".delivery-pay-total strong").text(endTotal);

        if (pricedetail == '') {
            $("#totalpriceshow").html(endTotal);
        } else {
            $("#totalpriceshow").html(endTotal);
            $("#youhui").html('已优惠:<em>{$setting['currency']}' + pricedetail + '</em>');

        }

//        changeBtnSelect();
        return endTotal;
    }
    tototal();//初始化金额


    function checkMobile($mobileVal) {
        if (checkEmpty($mobileVal) == false) {
            $.mvalidateTip("请输入手机号码");
            return false;
        } else {
            if ($mobileVal.length != 11) {
                $.mvalidateTip('手机号码长度不正确');
                return false;
            }
            else if (/^(((13[0-9]{1})|15[0-9]{1}|17[0-9]{1}|18[0-9]{1}|14[0-9]{1})+\d{8})$/.test($mobileVal) == false) {

                $.mvalidateTip('手机号码格式不正确');
                return false;
            }
            else {
                return true;
            }
        }
    }

    //非空校验
    function checkEmpty(param) {
        if (param == "" || param == null || param == undefined) {
            return false;
        } else {
            return true;
        }
    }

    function changeMealDate(obj) {
        var time1 = '{$select_mealtime}';
        var time2 = '{$select_mealtime2}';
        var curdate = "{$cur_date}";

        if (obj.value == curdate) {
            $("#meal_time").html(time1);
        } else {
            $("#meal_time").html(time2);
        }
    }

    function select_count(obj) {
        "{if $is_tea_money==1}"
        var count = obj.value;
        var teavalue = parseFloat($("#teavalue").val());
        var teatip = "{$teatip}";

        $("#totalteavalue").val(count * teavalue);
//        $("#show_tea").html(teatip + ':<i>{$setting['currency']}' + $("#totalteavalue").val() + '</i>');
        $("#show_tea").html('{$setting['currency']} ' + $("#totalteavalue").val());
        "{/if}"
        tototal();
    }

    function select_coupon(couponid) {
//        couponid = obj.value;
        if (couponid == 0) {
            $("#youhui").html('已优惠:<em>{$setting['currency']} 0</em>');
            $('#dprice').val('');
            tototal();
            return false;
        }

        if (true) {
            var url = "{php echo $this->createMobileUrl('selectcoupon', array('mode' => $mode), true)}";
            $.ajax({
                url: url, type: "post", dataType: "json", timeout: "10000",
                data: {
                    "couponid": couponid
                },
                success: function (data) {
                    if (data.status == 1) {
                        $('#dprice').val(data.dprice);
                    } else {
                        $('#dprice').val('');
                    }
                    tototal();
                },error: function () {

                }
            });
        }
    }

    $("#btnselect").click(function () {
        var bool = checkItem();
        if (bool) {
            postmain();
        }
    });

    function checkItem() {
        var ordertype = $("#mode").val();
        var meal_time = $("#meal_time").val();
        if (ordertype != 1 && ordertype != 4) {
            "{if $is_auto_address==0}"
            "{if empty($useraddress)}"
            $.mvalidateTip('请输入您的联系方式！');
            return false;
            "{/if}"
            "{/if}"
        }
        totalprice = parseFloat($("#totalprice").val());
//        if (totalprice <= 0) { ("金额为0，请选择商品！"); return false; }

        "{if $is_auto_address==1}"
        if (ordertype != 1 && ordertype != 4) {
            if (!checkMobile($("#tel").val())) {
                return false;
            }
            if ($("#username").val() == "" || $("#username").val() == "(必填*)请输入您的真实姓名") {
                $.mvalidateTip("请输入您的真实姓名！");
                return false;
            }
        }
        "{/if}"

        if (ordertype == 1) { //店内
            if ($("#counts").val() == "") {
                $.mvalidateTip("请输入用餐人数！");
                return false; }
            if (!new RegExp("^[0-9]*$").test($("#counts").val())) {
                $.mvalidateTip("用餐人数只能为数字！");
                return false; }
            if ($("#tables").val() == "") {
                $.mvalidateTip("请输入桌号！");
                return false; }
        } else if (ordertype == 2){//外卖
            "{if $is_auto_address==1}"
//            address = $("#address").val();
//            if (address == "" || address == "请输入您的联系地址！") { ("请输入您的联系地址！"); return false; }
            "{else}"
            "{if empty($useraddress)}"
            $.mvalidateTip('请先添加收餐地址！');
            return false;
            "{/if}"
            "{/if}"
            if (meal_time == '休息中') {
                $.mvalidateTip('未在配送时间！');
                return false;
            }
        }
        return true;
    }
$(document).ready(function() {
    "{if $couponid>0}"
    select_coupon({$couponid});
    "{/if}"
//    $(".fakeloader").fakeLoader({
//        timeToHide:1200,
//        bgColor:"#1abc9c",
//        spinner:"spinner6"
//    });
});

</script>
{php echo register_jssdk(false);}
<script type="text/javascript">
    function getaddress()
    {
        wx.ready(function () {
            wx.openAddress({
                trigger: function (res) {
                    $.mvalidateTip('用户开始拉出地址');
                },
                success: function (res) {
                    username = res.userName;
                    tel = res.telNumber;
                    address = res.detailInfo;
                    $("#tel").val(tel);
                    $("#name").val(username);
                    $("#address").val(address);
//                    $('.input-address').text(address);
                },
                cancel: function (res) {
                    $.mvalidateTip('请选择收货地址');
                },
                fail: function (res) {
                    $.mvalidateTip('请选择收货地址');
//                    (JSON.stringify(res));
                }
            });
        });
    }
</script>

	</body>
</html>
